/* Abstract Class ActionWidget
 * 
 * Extends PWF.Widget with action functionality
 * 
 * @author David Lindkvist (david.lindkvist@shapeshift.se)
 */


PWF.create('PWF.ActionWidget', 
			PWF.Widget,  
{
	/** Creates a new action using the provided name to look up the Url */
	createAction: function(/*String*/actionName,
						 	  /*method ptr*/callbackInit, 
						 	  /*method ptr*/callbackSuccess, 
						 	  /*method ptr*/callbackFailure, 
						 	  /*String*/method)
 	{
 		var actionUrl = this.getActionUrl(actionName);
		return this.createActionByUrl(actionUrl, callbackInit, callbackSuccess, callbackFailure, method);
	},
	/** Creates a new action using the provided Url */
	createActionByUrl: function(/*String*/actionUrl,
						 	 /*method ptr*/callbackInit, 
						 	 /*method ptr*/callbackSuccess, 
						 	 /*method ptr*/callbackFailure, 
						 	 /*String*/method)
 	{
		return new PWF.Action(actionUrl, 
							  callbackInit.bind(this), 
							  callbackSuccess.bind(this), 
							  callbackFailure.bind(this), 
							  method);
	},
	/** Returns a relative path to the specified action name */
	getActionUrl: function(/*String*/actionName) 
	{
		return this.getWidgetUrl() + '../../actions/' + actionName;
	}
});
